<?PHP
    $pp_path="..";
    include_once ($pp_path."/common.php");

    // Search API Key
    $query="SELECT p_apikey FROM gcm_project WHERE p_code='$p_code'";
    $project=$mysql->fetch($query);

    // Search Device Code Matching Project Code
    $query="SELECT d_code FROM gcm_device WHERE p_code='$p_code'";
    $result=$mysql->query($query);
    $device=array();
    while($row=$mysql->fetch_array($result)) {
        array_push($device, $row['d_code']);
    }

    if ($gcm_send=="N")
        $r_regdate="'".$reserve_year."-".$reserve_month."-".$reserve_day." ".$reserve_hour.":00:00'";
    else
        $r_regdate="";

    $query="INSERT INTO gcm_result (p_code, r_sender, r_subject, r_contents, r_status, r_regdate) VALUES ";
    $query.="('$p_code', '$gcm_sender', '".strip_tags($gcm_subject)."', '".strip_tags($gcm_contents)."', '2', UNIX_TIMESTAMP($r_regdate))";
    $result=$mysql->query($query);

    echo json_encode (array("result"=>$result, "message"=>$query));
?>